<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Document</title>
<script type="text/javascript" src="./js/angular.min.js"></script>
</head>
<body>
<div ng-app='myApp' ng-controller="myAppControl">
	<h4>直接过滤</h4>
	<p ng-repeat="x in list | filter:{name:'meizu'}">{{x.id}}----{{x.name}}----{{x.price}}</p>
	<hr>
	<h4>根据输入框过滤</h4>
	<input type="text" ng-model='searchStr'>
	{{searchStr}}
	<p ng-repeat="x in list | filter:{name:searchStr}">{{x.id}}----{{x.name}}----{{x.price}}</p> 
	<hr>
	<h4>自定义方法过滤</h4>
	<input type="text" ng-model='searchStrOne'>
	<p ng-repeat="x in list | filter:searchFun">{{x.id}}----{{x.name}}----{{x.price}}</p>
</div>
<script type="text/javascript">
var myApp = angular.module('myApp',[]);
myApp.service('produceData',function(){
	return [
		{id:1000,name:'iphone4',price:'4300'},
		{id:254,name:'meizu',price:'4400'},
		{id:358,name:'xiaomi',price:'450'},
		{id:485,name:'huawei',price:'800'},
		{id:9632,name:'vivo',price:'9000'},
	];
});
myApp.controller('myAppControl',function($scope,produceData){
	$scope.searchStr = '';
	$scope.list = produceData;
	$scope.searchStrOne = '';
	$scope.searchFun = function(obj){
		//console.log(obj); 传递过来的这个对象
		if(obj.name.indexOf($scope.searchStrOne) === -1 && obj.price.indexOf($scope.searchStrOne)){
			return false;
		};
		return true;
	};
});
</script>
</body>
</html>